package com.ltc.pomodoro.util;

import android.content.Context;
import android.content.SharedPreferences;

/**
 * 私有文件操作
 * @author litingchang
 *
 */
public class SharedPreferencesUtil {
	
	private static final String PREFS_NAME = "setting";
	
	private SharedPreferencesUtil() {}
	
	public static void putInt(Context context, String key, int value){
		SharedPreferences settings = context.getSharedPreferences(PREFS_NAME, 0);
		settings.edit()
		    .putInt(key, value)
		    .commit();
	}
	
	public static void putFloat(Context context, String key, float value){
		SharedPreferences settings = context.getSharedPreferences(PREFS_NAME, 0);
		settings.edit()
		    .putFloat(key, value)
		    .commit();

	}
	
	public static void putLong(Context context, String key, long value){
		SharedPreferences settings = context.getSharedPreferences(PREFS_NAME, 0);
		settings.edit()
		    .putLong(key, value)
		    .commit();

	}
	
	public static void putBoolean(Context context, String key, boolean value){
		SharedPreferences settings = context.getSharedPreferences(PREFS_NAME, 0);
		settings.edit()
		    .putBoolean(key, value)
		    .commit();

	}
	
	public static void putString(Context context, String key, String value){
		SharedPreferences settings = context.getSharedPreferences(PREFS_NAME, 0);
		settings.edit()
		    .putString(key, value)
		    .commit();

	}
	
	public static int getInt(Context context, String key, int defValue){
		SharedPreferences settings = context.getSharedPreferences(PREFS_NAME, 0);
		return settings.getInt(key, defValue);
	}
	

	public static float getFolat(Context context, String key, Float defValue){
		SharedPreferences settings = context.getSharedPreferences(PREFS_NAME, 0);
		return settings.getFloat(key, defValue);
	}

	public static long getLong(Context context, String key, long defValue){
		SharedPreferences settings = context.getSharedPreferences(PREFS_NAME, 0);
		return settings.getLong(key, defValue);	
	}

	public static boolean getBoolean(Context context, String key, boolean defValue){
		SharedPreferences settings = context.getSharedPreferences(PREFS_NAME, 0);
		return settings.getBoolean(key, defValue);
	}

	public static String getString(Context context, String key, String defValue){
		SharedPreferences settings = context.getSharedPreferences(PREFS_NAME, 0);
		return settings.getString(key, defValue);
	}

}
